/*****************************************************************************

File:   otkCreateNewCombStateExample.java

Date          Build     Author        Version    Comments
18-Sep-12    P-20-14    dshah          $$1        Created
20-mar-15 P-30-05 gshmelev $$2  called GetCurrentSession


****************************************************************************/

/*
  This example will work on the current Solid (Model/Assembly) as input and do the following: 
  - Creates new combined state by taking name as I/P from user.
*/

package com.ptc.otkjavaexamples;

import com.ptc.cipjava.*;
import com.ptc.pfc.pfcSession.*;
import com.ptc.pfc.pfcCommand.*;
import com.ptc.pfc.pfcGlobal.*;
import com.ptc.pfc.pfcModel.*;
import com.ptc.pfc.pfcModelItem.*;
import com.ptc.pfc.pfcFeature.*;
import com.ptc.pfc.pfcSolid.*;
import javax.swing.JOptionPane;
import java.io.*;

import com.ptc.cipjava.*;
import com.ptc.pfc.pfcFamily.*;
import com.ptc.pfc.pfcServer.*;
import com.ptc.pfc.pfcWindow.*;
import com.ptc.wfc.wfcSolid.*;
import com.ptc.wfc.wfcCombState.*;


// Creates new combined state
class otkCreateNewCombStateExample extends DefaultUICommandActionListener
{
    
    
    
    public otkCreateNewCombStateExample()
    {
    }
    
    
    
    
    public void OnCommand()
    {
	addCreateNewCombStateExample();
    }
    
    public int addCreateNewCombStateExample()
    {
	
	try
	    {
		FileWriter file = new FileWriter ("CombState.txt");
		BufferedWriter fp_out_combstate = new BufferedWriter(file);
		
		fp_out_combstate.write("- Combined State Example -");
		fp_out_combstate.newLine();
		fp_out_combstate.write("==============================");
		fp_out_combstate.newLine();
		
		Session session = pfcSession.GetCurrentSession ();
		
		WSolid myWSolid = (WSolid)(session.GetCurrentModel());
		
		session.UIDisplayMessage("combstate_msg.txt", "USER New Combined state Name", null);
		String NewCombStateName = session.UIReadStringMessage(null);
		
		CombState wCombState = otkCombStateUtils.otkUtilCreateCombinedState (myWSolid, NewCombStateName, false, fp_out_combstate); 
		
		fp_out_combstate.close();
		return 0;
	    }
	catch (Exception e)
	    {
		System.out.println("1: " + e);
	    }	
	return 0;
    }
    
    
};






